<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%
	String managerid = request.getParameter("managerid");
	if (managerid == null) {
		managerid = "";
	}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<jsp:include page="../inc/meta.jsp"></jsp:include>
<jsp:include page="../inc/easyui.jsp"></jsp:include>
<%--<link rel="stylesheet" href="<%=request.getContextPath()%>/plugins/uploadify3.2.1/uploadify.css" type="text/css"></link>
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/uploadify3.2.1/jquery.uploadify.js?f=<%=System.currentTimeMillis()%>"></script>--%>
<script type="text/javascript">
	var cbx_status = null;
	var managerForm = null;
	$(function() {
		managerForm = $('#managerForm').form();
		if ($(':input[name="manager_id"]').val().length > 0) {
			parent.$.messager.progress({
				text : '数据加载中....'
			});
			$.ajax({
				url : "getmanager",
				data : {
					managerid : $(':input[name="manager_id"]').val()
				},
				cache : false,
				dataType : "json",
				success : function(data) {
					
	                 managerForm.form('load', {
						manager_id : data.obj.manager_id,
						username : data.obj.username,
						name : data.obj.name,
						phone : data.obj.phone,
						phone1 : data.obj.phone1,
						id_num : data.obj.id_num,
						email : data.obj.email,
						address : data.obj.address,
						status : data.obj.status,
						userType : data.obj.userType,
						sex : data.obj.sex
						// photo : data.obj.photo
					});
					// $("#iframe").attr("src", data.obj.photo);
					var roles = data.obj.roleIds.split(",");
					 $('#roleIds').combobox('setValues', roles);
				}
			});
		}

		/*var f = "";
		$("#uploadify").uploadify({
			'swf' : '<%=request.getContextPath()%>/plugins/uploadify3.2.1/uploadify.swf?f=<%=System.currentTimeMillis()%>>',  
	        'uploader'      : '<%=request.getContextPath()%>/uploadFile?type=/img/manager',  
	        'height'        : 25,   
	        'width'         : 80,    
	        'buttonText'    : '浏览',  
	        'auto'          : true,
	        'queueID '      : 'false',
	        'fileSizeLimit' : '1024*1024*80', 
	        'fileTypeExts'  : '*.gif;*.jpg;*.jpeg;*.png;*.bmp', 
	        'uploadLimit' : 5, 
			'onUploadSuccess' : function(file, data, response) {
	            if (response) {
	            	
					var obj = eval('(' + data + ')');
	            	
	            	if(!obj.success){
                		$.messager.alert('提示', obj.msg, 'info');
                		return;
                	}
	            	
	            	$("#photo").val(obj.obj.substring(1));
	            	$("#iframe").attr('src',obj.obj);
	            	$.messager.show({
						msg : "图片上传成功!",
						title : '提示'
					});
				}else{
					$.messager.show({
						msg : "图片上传失败!",
						title : '提示'
					});
				}
	        },
			'onUploadError' : function(file, errorCode, errorMsg, errorString) {
	            alert('文件： ' + file.name + ' 不能被上传: ' + errorString);
	        }
    	}); */

	});

	var saveFun = function($dialog, datagrid, $parent) {
		managerForm.form("submit", {
			url : "addmanager",
			data : managerForm.serializeArray(),
			success : function(data) {
				var obj = eval('(' + data + ')');
				if (obj.success) {
					managerForm.form('clear');
					$dialog.dialog('destroy');
				}
				$parent.messager.alert('提示', obj.msg, 'info');
				datagrid.datagrid('reload');
			}
		});
	};

	var editF = function($dialog, datagrid, $parent) {
		managerForm.form('submit', {
			url : "editmanager",
			success : function(data) {
				var obj = eval('(' + data + ')');
				if (obj.success) {
					$dialog.dialog('destroy');
				}
				$parent.messager.alert('提示', obj.msg, 'info');
				datagrid.datagrid('reload');
			}
		});
	};
</script>

</head>

<body>
	<form id="managerForm" class="form" method="post">
		<fieldset>
			<legend>管理员基本信息</legend>
			<input type="hidden" name="manager_id" value="<%=managerid%>" />
			<input type="hidden" name="userType" value="1">
			<table class="table" style="width: 100%;">
				<tr>
					<th>用户名</th>
					<td><input name="username" type="text" style="width: 156px;"
						class="easyui-validatebox"
						data-options="required:'true',validType:'username'" maxlength="16" />
					</td>
					<th>姓名</th>
					<td><input name="name" type="text" style="width: 156px;"
						class="easyui-validatebox" required="true" maxlength="25" />
					</td>
				</tr>
				<tr>
					<th>性别</th>
					<td><select name="sex" id="sex" class="easyui-combobox"
						data-options="panelHeight:'auto',editable:false">
							<option value="1" id="option3">男</option>
							<option value="0" id="option4">女</option>
					</select>
					</td>
					<th>状态</th>
					<td><select name="status" class="easyui-combobox"
						data-options="panelHeight:'auto',editable:false">
							<option value="0" id="option5">生效</option>
							<option value="1" id="option6">失效</option>
					</select>
					</td>
				</tr>
				<tr>
					<th>手机</th>
					<td><input name="phone" type="text" style="width: 156px;"
						class="easyui-validatebox"
						data-options="required:'true',validType:'mobile'" />
					</td>
					<th>备用电话</th>
					<td><input name="phone1" id="phone1" type="text"
						style="width: 156px;" class="easyui-validatebox"
						data-options="validType:'tel'" maxlength="13" />
					</td>
				</tr>
				<tr>
					<th>证件号</th>
					<td><input name="id_num" type="text" style="width: 156px;"
						class="easyui-validatebox"
						data-options="required:'true',validType:'idcard'" />
					</td>
					<th>邮箱</th>
					<td><input name="email" type="text" style="width: 156px;"
						class="easyui-validatebox" data-options="validType:'email'"
						maxlength="25" />
					</td>
				</tr>
				<tr>
					<th>地址</th>
					<td colspan="3"><input name="address" type="text" style="width: 156px;"
						class="easyui-validatebox" maxlength="220" />
					</td>
				</tr>
				<%--<tr>
					<th>照片预览</th>
					<td colspan="3">
						<img src="images/defalut.jpg" name="iframe" id="iframe" style="width: 285px;height: 140px;"/>
					</td>
				</tr>
				<tr>
					<th>上传</th>
					<td colspan="3">
						<input id="uploadify" type="file" />
						<input type="hidden"  id="photo" name="photo">
					</td>
				</tr>--%>
			</table>
		</fieldset>
	</form>
</body>
</html>
